package zisu.algorithm.algorithm.LinkedList;

/**
 * @Author: 蔡翔
 * @Date: 2019/12/6 10:17
 * @Version 1.0
 */
public class Sum {
    public static int sum(int[] arr){
        //0 就是从0 开始 计算累加 到n-1
        return sum(arr,0);
    }
    private static int sum(int[] arr ,int l){
        if(l == arr.length){
            return 0;
        }
        return arr[l]+sum(arr,l+1);
    }

    public static void main(String[] args) {
        int[] num = {1,2,3,4,5,6,7,8,9};
        System.out.println(sum(num));
    }
}
